summaryrefslogtreecommitdiffstats
path: root/src/audio_core/renderer/command/data_source/decode.h
blob: 4d63d6fa8a2801c4c46a50b7e7447b8e89abe48c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <array>
#include <span>

#include "audio_core/common/common.h"
#include "audio_core/common/wave_buffer.h"
#include "audio_core/renderer/voice/voice_state.h"
#include "common/common_types.h"

namespace Core::Memory {
class Memory;
}

namespace AudioCore::AudioRenderer {

struct DecodeFromWaveBuffersArgs {
    SampleFormat sample_format;
    std::span<s32> output;
    VoiceState* voice_state;
    std::span<WaveBufferVersion2> wave_buffers;
    s8 channel;
    s8 channel_count;
    SrcQuality src_quality;
    f32 pitch;
    u32 source_sample_rate;
    u32 target_sample_rate;
    u32 sample_count;
    CpuAddr data_address;
    u64 data_size;
    bool IsVoicePlayedSampleCountResetAtLoopPointSupported;
    bool IsVoicePitchAndSrcSkippedSupported;
};

struct DecodeArg {
    CpuAddr buffer;
    u64 buffer_size;
    u32 start_offset;
    u32 end_offset;
    s8 channel_count;
    std::array<s16, 16> coefficients;
    VoiceState::AdpcmContext* adpcm_context;
    s8 target_channel;
    u32 offset;
    u32 samples_to_read;
};

/**
 * Decode wavebuffers according to the given args.
 *
 * @param memory - Core memory to read data from.
 * @param args - The wavebuffer data, and information for how to decode it.
 */
void DecodeFromWaveBuffers(Core::Memory::Memory& memory, const DecodeFromWaveBuffersArgs& args);

} // namespace AudioCore::AudioRenderer